﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtamajandusaastad_majaasta", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtamajandusaastadMajaasta))]
    public class MtamajandusaastadMajaastaSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtamajandusaastadMajaasta clazz;
        
        public MtamajandusaastadMajaastaSerializer(IMtamajandusaastadMajaasta clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.ReaId!=null) {
                Writer.WriteStartElement("rea_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.ReaId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Ark!=null) {
                Writer.WriteStartElement("ark");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Ark))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MajAastaAlgus!=null) {
                Writer.WriteStartElement("maj_aasta_algus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MajAastaAlgus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MajAastaLopp!=null) {
                Writer.WriteStartElement("maj_aasta_lopp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MajAastaLopp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKpv!=null) {
                Writer.WriteStartElement("algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKpv!=null) {
                Writer.WriteStartElement("lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="rea_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtamajandusaastad_majaasta>rea_id");
                }
                clazz.ReaId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("rea_id")).Value;
            }
            if (Reader.LocalName=="ark") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtamajandusaastad_majaasta>ark");
                }
                clazz.Ark = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark")).Value;
            }
            if (Reader.LocalName=="maj_aasta_algus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtamajandusaastad_majaasta>maj_aasta_algus");
                }
                clazz.MajAastaAlgus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("maj_aasta_algus")).Value;
            }
            if (Reader.LocalName=="maj_aasta_lopp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtamajandusaastad_majaasta>maj_aasta_lopp");
                }
                clazz.MajAastaLopp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("maj_aasta_lopp")).Value;
            }
            if (Reader.LocalName=="algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtamajandusaastad_majaasta>algus_kpv");
                }
                clazz.AlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kpv")).Value;
            }
            if (Reader.LocalName=="lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtamajandusaastad_majaasta>lopp_kpv");
                }
                clazz.LoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kpv")).Value;
            }
        }
    }
}
